/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.common.session.stateless;

import java.util.Collection;
import javax.ejb.Local;
import merlion.common.entity.SecurityRole;
import merlion.common.entity.AccessRight;
import merlion.common.entity.Staff;
import merlion.common.entity.SystemUserAccount;
import merlion.common.util.exception.NotExistException;
import merlion.common.util.exception.EntityExistException;
import merlion.common.util.exception.UpdateFailureException;

/**
 *
 * @author Zhang Ying
 */
@Local
public interface SystemUserSessionBeanLocal {
    public Collection<String> getAllDepartments();
    public Collection<SecurityRole> getAllSecurityRoles();
    public Long addNewSecurityRole(String roleName, String department, Collection<AccessRight> selectedRights) throws EntityExistException;
    public Long deleteSecurityRole(Long id) throws NotExistException;
    public Long updateSecurityRole(SecurityRole newRole) throws UpdateFailureException;
    public Long updateSecurityRole(SecurityRole newRole, Collection<AccessRight> updateAccessRights) throws UpdateFailureException;
    public SecurityRole getSecurityRole(Long id);
    public Collection<AccessRight> getAllAccessRights();
    public AccessRight getAccessRight(Long id);
    public Collection<AccessRight> getStaffAccessRights(String staffUsername);
    public void addNewStaff(Staff newStaff) throws EntityExistException;
    public Staff getStaff (String accountUsername) throws NotExistException;
    public boolean checkSystemUserAccountMatch(String username, String unencryptedPassword);
    public boolean checkSystemUserAccountMatchDisabled(String username, String unencryptedPassword);
    public boolean checkAccountStatusActivated(String username);
    public boolean checkUsernameExist(String username);
    public void updateStaffToken(String staffUsername, String token) throws UpdateFailureException;
    public boolean isTokenValid(String token);
    public SystemUserAccount updateSystemUserAccountStatus(String token) throws UpdateFailureException; // token = null & status= activated
    public Staff activateSytemUserAccount(SystemUserAccount sua) throws UpdateFailureException;
    public SystemUserAccount deactivateSystemUserAccount(String staffUsername);
    public Collection<SystemUserAccount> getAllSystemUserAccounts();
    public SystemUserAccount getSystemUserAccount(Long id);
    public SystemUserAccount getSystemUserAccount(String email);
    public void updateSystemUserAccount(SystemUserAccount sua, Collection<SecurityRole> updatedSecuirtyRoles) throws UpdateFailureException;
    public void updateSystemUserAccount(SystemUserAccount sua) throws UpdateFailureException;
    public void deleteSystemUserAccount(Long id) throws NotExistException;
    public boolean checkEmailExist(String emailInputed);
    public String getSecureQuestion(String email);
    public boolean checkSecureAnswer(String email, String ans);
    public void updateLoginTime(String staffUsername);
    public void updateCurrentStaffInfo(Staff currentStaff) throws UpdateFailureException;
    public Collection<Staff> getAllStaff();
    public Collection<Staff> getAllStaffbyDepartment(String department);
    public boolean checkRolenameExist(String nameInputed);
    public boolean checkAccountDisabled(String emailInputed);
    public boolean isAbleToDeleteRole(SecurityRole selectedRole);
    public Collection<SystemUserAccount> getFilteredAccounts(String rolename);
    public Staff getStaff(Long id);

    public SecurityRole getSecurityRole(String roleName);

    public boolean checkStaffIsSalesMgmtLevel(Long id);

    public boolean checkStaffIsFinMgmtLevel(Long id);

    public SystemUserAccount getRandomProductionMgmtLevelAccount();
}
